﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BezPanike.Domain;
using BezPanike.Domain.Services;

public partial class User_Default : System.Web.UI.Page
{
    KorisniciService korisniciService = new KorisniciService();

    protected void Page_Load(object sender, EventArgs e)
    {
        var prijavljen = User.Identity.IsAuthenticated;

        if (!prijavljen)
            Response.Redirect("../Error/Default.aspx");

        var korisnik = korisniciService.UzmiKorisnikaPoKorisnickomImenu(User.Identity.Name);
        lblDobrodosli.Text = "Dobrodosli " + korisnik.Ime + " " + korisnik.Prezime;
    }

    protected void Dodaj_OnClick(object sender, EventArgs e)
    {
        Linkovi link = new Linkovi();
        link.Url = tbUrl.Text;
        link.ImeFirme = tbImeFirme.Text;
        link.Opis = tbOpis.Text;
        link.Email = tbEmail.Text;
        link.KljucnaRec = tbKljucnaRec.Text;

        bool success = korisniciService.DodajLink(link);

        if (success)
            lblAddLinkStatus.Text = "Uspesno ste dodali link.";
        else
            lblAddLinkStatus.Text = "Dodavanje linka nije uspelo.";
    }
}
